# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Firegem <mrfiregem [at] protonmail [dot] ch>

pkgname=taplo-cli
pkgver=0.8.0
pkgrel=2
pkgdesc='TOML toolkit written in Rust'
arch=('loong64' 'x86_64')
url=https://taplo.tamasfe.dev/cli/introduction.html
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo')
provides=("${pkgname%-cli}")
options=('!lto')
source=("$pkgname-$pkgver.tar.gz::https://static.crates.io/crates/$pkgname/$pkgname-$pkgver.crate"
        "$pkgname-$pkgver-LICENSE.md::https://raw.githubusercontent.com/tamasfe/taplo/release-$pkgname-$pkgver/LICENSE.md")
b2sums=('0e494d171fc4f1ef972b4e4210b1a9f089976be24487d37c1155725757ca675c005445e91ed549c5062f72c145b23c63d17717c2eaba2c94dc5b3ac65c41fe25'
        '2b1282c2e1b54a67fd56894ae96a1447d954b52fecdf0730d8c3fe7a95ccf79245e738588a9bda7262eb0ef2507cdeded228346358894d4bbfc540ec90069964')

prepare() {
  cd $pkgname-$pkgver
#  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd $pkgname-$pkgver
  find -name Cargo.lock -exec rm -f {} \;
  mkdir -p .cargo
  cat > .cargo/config.toml <<EOF
[source.crates-io]
registry = "https://gitee.com/yetist/crates.io-index"
EOF
  cargo build --release --offline --all-features
}

package() {
  cd $pkgname-$pkgver
  install -Dt "$pkgdir"/usr/bin target/release/${pkgname%-cli}
  install -Dm644  ../$pkgname-$pkgver-LICENSE.md "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.md
}
